<template>
    <div id="home">
      <HomeHeader></HomeHeader>
      <HomeBanner></HomeBanner>
      <HomeSwiper></HomeSwiper>
      <Homediscount></Homediscount>
      <tuijian></tuijian>
      <shaixuan ref='fixed' :res='icon'></shaixuan>
      <leibiao @events='callback'></leibiao>
      <qiehuan :pages='1'></qiehuan>
    </div>
</template>
<script>
import HomeHeader from '@/components/home/home-list/HomeHeader'
import HomeBanner from '@/components/home/home-list/HomeBanner'
import HomeSwiper from '@/components/home/home-list/HomeSwiper'
import Homediscount from '@/components/home/home-list/Homediscount'
import tuijian from '@/components/home/home-list/tuijian'
import shaixuan from '@/components/home/home-list/shaixuan'
import leibiao from '@/components/home/home-list/leibiao'
import qiehuan from '@/common/qiehuan'
export default {
    components:{
        HomeHeader,
        HomeBanner,
        HomeSwiper,
        Homediscount,
        tuijian,
        leibiao,
        shaixuan,
        qiehuan
    },
    data(){
        return {
            icon:false,
            offsettop:0,
            id:''
        }
    },
    mounted() {
            this.offsettop = this.$refs.fixed.$el.offsetTop
            window.addEventListener('scroll',this.handlescroll)
            // console.log('一',this.$refs.fixed.$el.offsetTop)
        },
        destroyed() {
            window.removeEventListener('scroll',this.handlescroll)
        },
    methods:{
        handlescroll(){
            
                var scrolltop = window.pageYOffset || document.documentElement.scrollTop||document.body.scrollTop
                // console.log('1',scrolltop,this.offsettop+202)
                if(scrolltop>=this.offsettop+202){
                    // console.log('肖国锋')
                    this.icon=true
                }else{
                    this.icon=false
                }
            },
            callback(msg){
                    this.id=msg
            }
    }
}
</script>
<style lang="stylus" scoped>
    
</style>


